<?php
if (file_exists("config.php"))
	require_once("config.php");
else
	require_once("config.php");

if (file_exists("functions.php"))
	require_once("functions.php");
else
	require_once("functions.php");

if (!$allow_url_fopen) {
	echo '<span class="error"><b>Note</b>: Please enable \'<em>allow_url_fopen</em>\' option in PHP configuration file</span><br/>';
}

if (file_exists("MSN.php"))
	require_once("MSN.php");
else
	require_once("MSN.php");

$g = new MSN();

$domain = $_REQUEST['domain'];
$start = @$_REQUEST['start'];
if (empty($start) ) $start = 0;
$search_links = array();
$total_links = 0;

if (!empty($domain) ) {

	list($with_www, $without_domain) = get_domain($domain);

	$search_links = $g->get_links($without_domain."&first=".$start);
	$total_links = $g->get_response($without_domain."&first=".$start);
}

?>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="top"><table width="99%" border="0" cellspacing="1" cellpadding="0">
      <tr class="headingbar" height="26">
        <td width="3%" align="center">&nbsp;</td>
        <td width="67%" align="center"><strong>Link URL </strong></td>
        <td width="13%" align="center"><strong>Page Rank</strong></td>
        <td width="13%" align="center"><strong>IP Address </strong></td>
		<td width="4%" align="center"></td>
      </tr>
<?php
$count = $start+1;
foreach ($search_links as $link ) 
{
?>
      <tr class="tr1" height="25">
        <td align="left"><?php echo $count; ?></td>
        <td align="left"><?php echo $link['link']; ?></td>
        <td><img src="http://pr.blogflux.com/pr3.php?s=<?php echo $link['link']; ?>" align="top" alt="Page Rank" /></td>
        <td  align="right"><?php echo $link['ip']; ?></td>
		<td width="4%" align="center"><a href="javascript: show_additionals('div_<?php echo $count; ?>');">[+]</a></td>
      </tr>
      <tr class="tr2">
	    <td>&nbsp;</td>
        <td align="left" colspan="4"><div id="div_<?php echo $count; ?>" style="display:none"><?php echo '<b>'.$link['atext'].'</b><br><br>'.@$link['text']; ?></div></td>
      </tr>
<?php
$count++;
}
?>
    </table></td>
  </tr>
  <tr>
    <td height="25" align="right"><?php echo pager($start,$total_links,'query_msn.php?domain='.$domain,10,'div_msn'); ?></td>
  </tr>
</table>
<script>
function show_additionals(divid) {
	if( document.getElementById(divid).style.display == 'none' ) {
		document.getElementById(divid).style.display = 'block';
	} else {
		document.getElementById(divid).style.display = 'none';
	}
}
</script>